package cn.laixueit.cart.controller;

import cn.laixueit.cart.pojo.Goods;
import cn.laixueit.cart.pojo.SearchRequest;
import cn.laixueit.cart.pojo.page.PageResult;
import cn.laixueit.cart.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Controller
public class SearchController {

    @Autowired
    private SearchService searchService;

    @PostMapping("/page")
    public ResponseEntity<PageResult<Goods>> page(@RequestBody SearchRequest searchRequest){

        PageResult<Goods> goodsList =  searchService.page(searchRequest);

        return ResponseEntity.ok(goodsList);
    }

}
